<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户主页</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="/js/jquery-3.6.4.js"></script>
    <style>
        body {
            font-family: '微软雅黑', Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f4f4f4;
        }
        .user-container {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            text-align: center;
            width: 90%;
            max-width: 600px;
        }
        .welcome-message {
            margin-bottom: 20px;
        }
        .user-action-button {
            padding: 10px 20px;
            margin: 5px;
            font-size: 16px;
            border: none;
            border-radius: 5px;
            color: white;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .edit-profile-btn {
            background-color: #007BFF;
        }
        .edit-profile-btn:hover {
            background-color: #0056b3;
        }
        .borrow-book-btn {
            background-color: #287ee1;
        }
        .borrow-book-btn:hover {
            background-color: #0e3b80;
        }
        .return-book-btn {
            background-color: #1c92e7; /* 设置还书按钮的颜色 */
        }
        .return-book-btn:hover {
            background-color: #0e3b80; /* 设置鼠标悬停时的颜色 */
        }
    </style>
</head>
<body>
<div class="user-container">
    <div class="welcome-message">
        <h2>欢迎, <span id="userDisplayName"></span>!</h2>
    </div>
    <div class="user-action-buttons">
        <button id="editProfileBtn" class="user-action-button edit-profile-btn">更新用户信息</button>
        <button id="returnBookBtn2" class="user-action-button return-book-btn">借阅排行榜</button>
        <button id="borrowBookBtn" class="user-action-button borrow-book-btn">借书</button>
        <button id="returnBookBtn" class="user-action-button return-book-btn">还书</button>
        <button id="returnBookBtn1" class="user-action-button return-book-btn">借阅历史</button>

    </div>
</div>

<!-- 引入 JavaScript -->
<script>
    $(document).ready(function() {
        var urlParams = new URLSearchParams(window.location.search);
        var userId = urlParams.get('id');
        var displayName = userId ? '用户 ' + userId : '访客';
        $('#userDisplayName').text(displayName);

        // 按钮点击事件处理
        $('#editProfileBtn').click(function () {
            window.location.href = '/updateuser?id=' + userId;
        });
        $('#borrowBookBtn').click(function () {
            window.location.href = '/borrowbook?id=' + userId;
        });
        $('#returnBookBtn').click(function () {
            window.location.href = '/borrowedBooks?id=' + userId;
        });
        $('#returnBookBtn1').click(function () {
            window.location.href = '/userborrowrecordslist?id=' + userId;
        });
        $('#returnBookBtn2').click(function () {
            window.location.href = '/borrowrank?id=' + userId;
        });
    });
</script>
</body>
</html>